package com.zdkj.subway.st.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.st.entity.SwStCleanPlanDetail;
import com.zdkj.subway.st.service.SwStCleanPlanDetailService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("/swStCleanPlanDetail")
@Api(value = "swStCleanPlanDetail", tags = "车票清洗计划明细")
public class SwStCleanPlanDetailController {
	private final SwStCleanPlanDetailService swStCleanPlanDetailService;

	@GetMapping("/{id}")
	public R getById(@PathVariable String id) {
		return R.ok(swStCleanPlanDetailService.getById(id));
	}

	@GetMapping("/page")
	public R<IPage> getDictPage(Page page, SwStCleanPlanDetail swStCleanPlanDetail) {
		return R.ok(swStCleanPlanDetailService.page(page, Wrappers.query(swStCleanPlanDetail)));
	}

	@SysLog("车票清洗计划制定")
	@PostMapping
	public R save(@Valid @RequestBody SwStCleanPlanDetail swStCleanPlanDetail) {
		return R.ok(swStCleanPlanDetailService.save(swStCleanPlanDetail));
	}

	@SysLog("删除车票清洗计划制定")
	@DeleteMapping("/{id}")
	public R removeById(@PathVariable String id) {
		return R.ok(swStCleanPlanDetailService.removeById(id));
	}

	@PutMapping
	@SysLog("修改车票清洗计划制定")
	public R updateById(@Valid @RequestBody SwStCleanPlanDetail swStCleanPlanDetail) {
		return R.ok(swStCleanPlanDetailService.updateById(swStCleanPlanDetail));
	}

}
